package com.intellagric.controller.module.ift_equipment_channel;

import com.intellagric.common.pojo.LayuiDataGridResult;
import com.intellagric.common.pojo.ResponseMessage;
import com.intellagric.module.iftmonitor.EquipmentChannelVo;
import com.intellagric.pojo.IftEquipmentChannel;
import com.intellagric.service.iftmonitor.ift_equipment_channel.EquipmentChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.UUID;

/**
 * @Author: zhy
 * @email: 1269679946@qq.com
 * @Date: 2018/12/13
 * @DESC： 采集设备通道管理
 */
@Controller
public class EquipmentChannelController {

    @Autowired
    private EquipmentChannelService equipmentChannelService;

    /**
     * 添加采集设备通道
     * @Param
     * @return ResponseMessage
     */
    @RequestMapping("/equipment/channel/add")
    @ResponseBody
    public ResponseMessage add(IftEquipmentChannel equipmentChannel) {
        equipmentChannel.setRelChannelId(UUID.randomUUID().toString().replaceAll("-",""));
        equipmentChannel.setCreateDate(new Date());
        equipmentChannel.setUpdateDate(new Date());
        return equipmentChannelService.addEquipmentChannel(equipmentChannel);
    }


    /**
     * 删除采集设备通道
     * @Param id
     * @return ResponseMessage
     */
    @RequestMapping("/equipment/channel/delete")
    @ResponseBody
    public ResponseMessage delete(String id) {
        return equipmentChannelService.deleteEquipmentChannel(id);
    }

    /**
     * 修改采集设备通道
     * @Param
     * @return ResponseMessage
     */
    @RequestMapping("/equipment/channel/edit")
    @ResponseBody
    public ResponseMessage edit(IftEquipmentChannel equipmentChannel) {
        equipmentChannel.setUpdateDate(new Date());
        return equipmentChannelService.editEquipmentChannel(equipmentChannel);
    }

    /**
     * 查询采集设备通道
     * @return IftEquipmentChannel
     */
    @RequestMapping("/equipment/channel/{id}")
    @ResponseBody
    public IftEquipmentChannel get(@PathVariable String id) {
        return equipmentChannelService.getEquipmentChannelById(id);
    }

    /**
     * 查询采集设备通道列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/equipment/channel/list")
    @ResponseBody
    public LayuiDataGridResult getList() {
        return equipmentChannelService.getEquipmentChannelList();
    }

    /**
     * 多条件查询采集设备通道列表
     * @return LayuiDataGridResult
     */
    @RequestMapping("/equipment/channel/query")
    @ResponseBody
    public LayuiDataGridResult getListByVo(EquipmentChannelVo equipmentChannelVo) {
        return equipmentChannelService.getEquipmentChannelListByVo(equipmentChannelVo);
    }

}
